#!/bin/bash
#
read -p "用户名：" name

#判断用户是否存在
id ${name} &> /dev/null
if [ $? -eq 0 ]; then
    echo "用户${name}已存在"
else
    read -p "密码：" password
    useradd ${name}
    echo "${password}" | passwd --stdin ${name} &> /dev/null

echo "用户${name}创建完成，初始化密码是${password}"
fi
